import instance from "@/request/request";
import type { Res } from '@/request/ResultApi';

// 登录
export const loginAPI = (data: { username: String, password: String }): Res<null> =>
    instance.post("/users/login", data);

//获取所有用户
export const getAllUser = (size: number, current: number, username: String): Res<null> =>
    instance.get(`/users/all?size=${size}&current=${current}&username=${username}`);

//添加用户
export const addUser = (data: {
    name: String,
    username: String,
    password: String,
    msg: String
}): Res<null> => instance.post("/users/add", data);

//修改用户
export const updateUser = (data: {
    userId: String,
    name: String,
    username: String,
    msg: String
}): Res<null> => instance.post("/users/update", data);

//删除用户
export const removeUser = (userId: number): Res<null> =>
    instance.post(`/users/delete?userId=${userId}`);

//批量删除用户
export const removeUsers = (data: []): Res<null> => instance.post("/users/deletes", data);
//获取当前登录用户
export const getMe = (): Res<null> => instance.get("/users/getCurrUser");
